package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.controller.PageResult;
import com.itheima.mapper.LogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;
    
    @Override
    public PageResult page(Integer page, Integer pageSize) {
        //开启分页
        PageHelper.startPage(page, pageSize);
        //调用mapper分页查询
        Page<OperateLog> logPage = logMapper.page(page, pageSize); // 添加分页参数
        //封装PageResult并返回
        return new PageResult(logPage.getTotal(), logPage.getResult());
    }
}